package com.atguigu.wordcount.groupcomparator;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @ClassName OrderMapper
 * @DeScription OrderMapper
 * @Author 剧情再美终是戏
 * @Date 2019/11/19 15:19
 * @Version 1.0
 **/
// 10000001	Pdt_01	222.8
public class OrderMapper extends Mapper<LongWritable, Text, Order, NullWritable> {

    private Order out_key = new Order();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] splits = value.toString().split("\t");

        out_key.setId(splits[0]);
        out_key.setPid(splits[1]);
        out_key.setPrice(Double.parseDouble(splits[2]));

        context.write(out_key, NullWritable.get());
    }
}
